﻿package extremefx.ui {
	import flash.display.Sprite;
	import flash.display.Stage;		

	/**
	 * @author Marcelo Volmaro
	 */
	public class UIStage {
		public static var STAGE:Stage;
		public static var ROOT:Sprite;
		public static var WINDOWS:Sprite;
		public static var MISC:Sprite;
		public static var MODALS:Sprite;
		public static var WINDOWFX:Sprite;
		public static var DROPDOWNS:Sprite;
		public static var TOOLTIPS:Sprite;
		public static var ERRORS:Sprite;
		public static var DRAGNDROP:Sprite;
		public static var CURSORS:Sprite;

		public static function init(pStage:Stage):void {
			STAGE = pStage;
//			pStage.addEventListener(Event.RESIZE, _resizeStage);

			ROOT = new Sprite();
			pStage.addChild(ROOT);

			WINDOWS = new Sprite();
			pStage.addChild(WINDOWS);
			
			MISC = new Sprite();
			pStage.addChild(MISC);
			
			MODALS = new Sprite();
			pStage.addChild(MODALS);
			
			WINDOWFX = new Sprite();
			pStage.addChild(WINDOWFX);
			
			DROPDOWNS = new Sprite();
			pStage.addChild(DROPDOWNS);
			
			TOOLTIPS = new Sprite();
			pStage.addChild(TOOLTIPS);
			
			ERRORS = new Sprite();
			pStage.addChild(ERRORS);
			
			DRAGNDROP = new Sprite();
			pStage.addChild(DRAGNDROP);
			
			CURSORS = new Sprite();
			pStage.addChild(CURSORS);
			
			KeyHandler.instance;//force instantiation
		}
		
		public static function get mouseX():int {
			return int (STAGE.mouseX);
		}
		
		public static function get mouseY():int {
			return int (STAGE.mouseY);
		}
		
		public static function addEventListener(pEvent:String, pHandler:Function):void {
			STAGE.addEventListener(pEvent, pHandler, false, 0, true);
		}
		
		public static function removeEventListener(pEvent:String, pHandler:Function):void {
			STAGE.removeEventListener(pEvent, pHandler);
		}
	}
}
